<div class="modal-header">
  <button type="button" class="close self-start" data-dismiss="modal" aria-label="Close">
          <i class="sn-icon sn-icon-close"></i>
  </button>
  <h4 class="modal-title">
    <% if downstream %>
      <%= t('my_modules.modals.assign_repository_record.title_downstream',
            repository_name: repository.name) %>
    <% else %>
      <%= t('my_modules.modals.assign_repository_record.title',
            repository_name: repository.name,
            my_module_name: my_module.name) %>
    <% end %>
  </h4>
</div>
<div class="modal-body">
  <p>
    <% if downstream %>
      <%= t('my_modules.modals.assign_repository_record.message_downstream', size: selected_rows.count) %>
    <% else %>
      <%= t('my_modules.modals.assign_repository_record.message', size: selected_rows.count) %>
    <% end %>
  </p>
  <% if downstream %>
    <div class='my-modules-to-assign'>
      <% visible_modules = 0
         downstream_modules = my_module.downstream_modules
         downstream_modules.each do |m| %>
        <% if can_assign_my_module_repository_rows?(m) %>
          <div class='my-module-to-assign'>
            <% if m == my_module %>
              <span class="current-task"><%= t('my_modules.modals.assign_repository_record.current_task') %></span>
            <% end %>
            <%= m.name %>
          </div>
          <% visible_modules += 1 %>
        <% end %>
      <% end %>
    </div>
    <% if visible_modules != downstream_modules.size %>
      <div class="hidden-my-modules">
        <i class="fas fa-exclamation-triangle"></i>
        <%= t('my_modules.modals.assign_repository_record.hidden_tasks', size: (downstream_modules.size - visible_modules)) %>
      </div>
    <% end %>
  <% end %>
</div>
<div class="modal-footer">
  <div class="sci-btn-group">
    <a class="btn btn-secondary hide-assign-repo-modal" data-dismiss="modal">
      <%= t('general.cancel') %>
    </a>
    <% if downstream %>
      <a class="btn btn-primary downstream-action">
        <%= t('my_modules.modals.assign_repository_record.task_and_downstream') %>
      </a>
    <% else %>
      <a class="btn btn-primary task-action">
        <%= t('my_modules.modals.assign_repository_record.task') %>
      </a>
    <% end %>
  </div>
</div>
